Socket
Socket
Sign inDemoInstall

npmlog

Package Overview
Dependencies
Maintainers
4
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npmlog

logger for npm


Version published
Weekly downloads
18M
decreased by-1.88%
Maintainers
4
Weekly downloads
 
Created

What is npmlog?

The npmlog package is a logger for Node.js that is used by npm. It provides various logging levels and methods to output messages with different importance. It is designed to be both a core library for logging within npm itself as well as a tool for developers to use in their own applications.

What are npmlog's main functionalities?

Logging at different levels

npmlog provides methods to log messages at predefined levels such as info, warn, and error. Each level is associated with a method that takes a prefix and a message.

const log = require('npmlog');

log.info('info', 'This is an informational message');
log.warn('warn', 'This is a warning message');
log.error('error', 'This is an error message');

Custom log levels

Developers can define custom log levels with a specific numeric priority and styling options.

const log = require('npmlog');

log.addLevel('success', 2000, { fg: 'green', bold: true });
log.success('success', 'This is a success message');

Prefixing log messages

npmlog allows setting a global prefix that will be prepended to all log messages, which is useful for distinguishing logs from different parts of an application.

const log = require('npmlog');

log.heading = 'myapp';
log.info('info', 'This message will be prefixed with myapp');

Adjusting log output level

The verbosity of the log output can be controlled by setting the log.level property. Only messages at or above the specified level will be output.

const log = require('npmlog');

log.level = 'warn';
log.info('info', 'This message will not be printed');
log.warn('warn', 'This message will be printed');

Other packages similar to npmlog

FAQs

Package last updated on 26 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc